#ifndef __SMARTHOMEMONITORSERVER_H__
#define __SMARTHOMEMONITORSERVER_H__

#include "ThreadPool.h"
#include "TcpServer.h"
#include "MySQLClient.h"

using namespace myNameSpace;

class SmartHomeMonitorServer {
public:
    SmartHomeMonitorServer(size_t threadNum, size_t queueSize, unsigned short port, const string &ip = "127.0.0.1",
                           const string &host = "localhost", const string &user = "root", const string &password = "1234",
                           const string &database = "smart_monitor_system", unsigned short mysqlPort = 0);

    void start();
    void stop();

private:
    void onNewConnection(shared_ptr<TcpConnection> pTcpConnection);
    void onMessage(shared_ptr<TcpConnection> pTcpConnection);
    void onClose(shared_ptr<TcpConnection> pTcpConnection);

private:
    ThreadPool _threadPool;
    TcpServer _tcpServer;
    MySQLClient _mysqlClient;
};

#endif
